export async function async1() {
  console.log("async1")
}

export async function async2() {
  await Sleep(3000)
  console.log("async2")
}

export const Sleep = (ms) => {
  return new Promise(resolve => setTimeout(resolve, ms))
}

async function async3() {
  try {
    // 添加await才能捕获异常
    await Promise.reject('error')
  } catch (e) {
    //04-28 23:11:36.463   25351-25351  A03d00/JSAPP                   com.examp...lication  I     async3 error error
    console.log('async3 error', e)
  }
}

async function async4(): Promise<string> {
  return 'test'
}

export async function testAsync() {
  await async1()
  await async2()
  await async3()
  const value = await async4()
  console.log('testAsync async4 value', value)
}